var getOptions = function(id, obj) {
  var data = [];
  if (id == "id") {
    for (var i = 0; i < obj.length; i++) {
      var arr = {};
      arr["value"] = obj[i].id;
      arr["label"] = obj[i].title;
      if (obj[i].z != undefined) {
        var firstChild = [];
        for (var j = 0; j < obj[i].z.length; j++) {
          var firstChilditem = {};
          firstChilditem["value"] = obj[i].z[j].id;
          firstChilditem["label"] = obj[i].z[j].title;
          var three = [];
          if (obj[i].z[j].z !== undefined) {
            for (var k = 0; k < obj[i].z[j].z.length; k++) {
              var threeItem = {};
              threeItem["value"] = obj[i].z[j].z[k].id;
              threeItem["label"] = obj[i].z[j].z[k].title;
              three.push(threeItem);
            }
            firstChilditem["children"] = three;
          }
          firstChild.push(firstChilditem);
        }
        arr["children"] = firstChild;
      }
      data.push(arr);
    }
  } else if (id == "parent_id") {
    for (var a = 0; a < obj.length; a++) {
      var arrr = {};
      arrr["value"] = obj[a].parent_id+obj[a].title;
      arrr["label"] = obj[a].title;
      if (obj[a].z != undefined) {
        var firstChildl = [];
        for (var b = 0; b < obj[a].z.length; b++) {
          var firstChilditeml = {};
          firstChilditeml["value"] = obj[a].z[b].parent_id+obj[a].z[b].title;
          firstChilditeml["label"] = obj[a].z[b].title;
          var threel = [];
          if (obj[a].z[b].z !== undefined) {
            for (var c = 0; c < obj[a].z[b].z.length; c++) {
              var threeIteml = {};
              threeIteml["value"] = obj[a].z[b].z[c].parent_id+obj[a].z[b].z[c].title;
              threeIteml["label"] = obj[a].z[b].z[c].title;
              threel.push(threeIteml);
            }
            firstChilditeml["children"] = threel;
          }
          firstChildl.push(firstChilditeml);
        }
        arrr["children"] = firstChildl;
      }
      data.push(arrr);
    }
  }
  return data;
};
export default getOptions;
